Full source code website bán hàng thương mại điện tử gần giống shopee
468.803 lượt xem;
1 <table height="28" cellSpacing="0" cellPadding="0" width="100%" border="0">
2 <tr align=center>
3 <td class="title" width="100%" height="17">
4 Online : <b> <a href="./?act=online_m"><font color="#FFFFFF">Nhập
5 mới</font></a><font color="#FFFFFF"> </font></b></td>
6 </tr>
7 </table>
8 <?
9 switch ($_GET['action'])
10 {
11 case 'del' :
12 $id = $_GET['id'];
13 $sql = "delete from support where id='".$id."'";
14 @$result = mysql_query($sql,$con);
15 if ($result) echo "<p align=center class='err'>Đã xóa thành công</p>";
16 else echo "<p align=center class='err'>Không thể xóa dữ liệu</p>";
17 break;
18 }
19 ?>
20
21 <?
22 if (isset($_POST['ButDel'])) {
23 $cnt=0;
24 foreach ($_POST['chk'] as $id)
25 {
26 @$result = mysql_query("delete from support where id='".$id."'",$con);
27 if ($result) $cnt++;
28 }
29 echo "<p align=center class='err'>Đã xóa ".$cnt." phần tử</p>";
30 }
31 ?>
32 <?
33 $page = $_GET["page"];
34 $MAXPAGE=10;
35 $p=0;
36 if ($page!='') $p=$page;
37 ?>
38 <form method="POST" action="<? echo $_SERVER[PHP_SELF]; ?>" name="frmList">
39 <input type="hidden" name="act" value="online">
40 <input type=hidden name="page" value="<? echo $page; ?>">
41 <?
42 function taotrang($sql,$link,$nitem,$itemcurrent)
43 { global $con;
44 $ret="";
45 $result = mysql_query($sql, $con) or die('Error' . mysql_error());
46 $value = mysql_fetch_array($result);
47 $plus = (($value['cnt'] % $nitem)>0);
48 for ($i=0;$i<($value[0] / $nitem) + plus;$i++)
49 {
50 if ($i<>$itemcurrent) $ret .= "<a href=\"".$link.$i."\" class=\"lslink\">".($i+1)."</a> ";
51 else $ret .= ($i+1)." ";
52 }
53 return $ret;
54 }
55 $pageindex=taotrang("select count(*) from support","./?act=online"."&page=",$MAXPAGE,$page);
56 ?>
57
58 <table cellspacing="0" cellpadding="0">
59 <tr>
60 <td class="smallfont">Trang : <? echo $pageindex; ?></td>
61 </tr>
62 </table>
63
64 <table border="1" cellpadding="2" style="border-collapse: collapse" bordercolor="#C9C9C9" width="100%" id="AutoNumber1">
65 <tr>
66 <td align=center nowrap class="title"><input type="checkbox" name="chkall" onclick="chkallClick(this);"></td>
67 <td nowrap class="title"> </td>
68 <td nowrap class="title"> </td>
69 <td align="center" nowrap class="title"><b>Mã</b></td>
70 <td align="center" nowrap class="title"><b>Tên trực tuyến</b></td>
71 <td align="center" nowrap class="title"><b>Yahoo ID</b></td>
72 <td align="center" nowrap class="title"><b>Điện thoại</b></td>
73 <td align="center" nowrap class="title"><b>Email</b></td>
74 <td align="center" nowrap class="title"><b>Thu tu</b></td>
75 <td align="center" nowrap class="title"><b>Ngày</b></td>
76 </tr>
77
78 <?
79 $sql="select * from support order by id limit ".($p*$MAXPAGE).",".$MAXPAGE;
80 $result=mysql_query($sql,$con);
81 $i=0;
82 while(($row=mysql_fetch_array($result)))
83 {
84 $i++;
85 if ($i%2) $color="#d5d5d5"; else $color="#e5e5e5";
86 ?>
87
88 <tr>
89 <td width="20" align="center" bgcolor="<? echo $color; ?>" class="smallfont">
90 <input type="checkbox" name="chk[]" value="<? echo $row['id']; ?>"></td>
91 <td width="20" bgcolor="<? echo $color; ?>" class="smallfont">
92 <a href="./?act=online_m&page=<? echo $_REQUEST['page']; ?>&id=<? echo $row['id']; ?>">Sửa</a></td>
93 <td width="20" bgcolor="<? echo $color; ?>" class="smallfont">
94 <a onclick="return confirm('Bạn có chắc chắn muốn xoá ?');" href="./?act=online&action=del&page=<? echo $_REQUEST['page']; ?>&id=<? echo $row['id']; ?>">Xoá</a></td>
95 <td width="20" bgcolor="<? echo $color; ?>" align="left" width="55" align="left" class="smallfont"><? echo $row['id']; ?> </td>
96 <td bgcolor="<? echo $color; ?>" class="smallfont"><? echo $row['name']; ?> </td>
97 <td bgcolor="<? echo $color; ?>" class="smallfont"><? echo $row['yahoo']; ?> </td>
98 <td width="80" bgcolor="<? echo $color; ?>" class="smallfont"><? echo $row['phone']; ?> </td>
99 <td width="80" bgcolor="<? echo $color; ?>" class="smallfont"><? echo $row['email']; ?> </td>
100 <td width="80" bgcolor="<? echo $color; ?>" class="smallfont"><? echo $row['thutu']; ?> </td>
101 <td width="100" bgcolor="<? echo $color; ?>" class="smallfont"><? echo $row['date']; ?> </td>
102 </tr>
103 <?
104 }
105 ?>
106 </table>
107 <input type="submit" value="Xóa Chọn" name="ButDel" onclick="return confirm('Bạn có chắc chắn muốn xoá ?');" class="button" style="padding: 0">
108 </form>
109 <script language="JavaScript">
110 function chkallClick(o) {
111 var form = document.frmList;
112 for (var i = 0; i < form.elements.length; i++) {
113 if (form.elements[i].type == "checkbox" && form.elements[i].name!="chkall") {
114 form.elements[i].checked = document.frmList.chkall.checked;
115 }
116 }
117 }
118 </script>
2 <tr align=center>
3 <td class="title" width="100%" height="17">
4 Online : <b> <a href="./?act=online_m"><font color="#FFFFFF">Nhập
5 mới</font></a><font color="#FFFFFF"> </font></b></td>
6 </tr>
7 </table>
8 <?
9 switch ($_GET['action'])
10 {
11 case 'del' :
12 $id = $_GET['id'];
13 $sql = "delete from support where id='".$id."'";
14 @$result = mysql_query($sql,$con);
15 if ($result) echo "<p align=center class='err'>Đã xóa thành công</p>";
16 else echo "<p align=center class='err'>Không thể xóa dữ liệu</p>";
17 break;
18 }
19 ?>
20
21 <?
22 if (isset($_POST['ButDel'])) {
23 $cnt=0;
24 foreach ($_POST['chk'] as $id)
25 {
26 @$result = mysql_query("delete from support where id='".$id."'",$con);
27 if ($result) $cnt++;
28 }
29 echo "<p align=center class='err'>Đã xóa ".$cnt." phần tử</p>";
30 }
31 ?>
32 <?
33 $page = $_GET["page"];
34 $MAXPAGE=10;
35 $p=0;
36 if ($page!='') $p=$page;
37 ?>
38 <form method="POST" action="<? echo $_SERVER[PHP_SELF]; ?>" name="frmList">
39 <input type="hidden" name="act" value="online">
40 <input type=hidden name="page" value="<? echo $page; ?>">
41 <?
42 function taotrang($sql,$link,$nitem,$itemcurrent)
43 { global $con;
44 $ret="";
45 $result = mysql_query($sql, $con) or die('Error' . mysql_error());
46 $value = mysql_fetch_array($result);
47 $plus = (($value['cnt'] % $nitem)>0);
48 for ($i=0;$i<($value[0] / $nitem) + plus;$i++)
49 {
50 if ($i<>$itemcurrent) $ret .= "<a href=\"".$link.$i."\" class=\"lslink\">".($i+1)."</a> ";
51 else $ret .= ($i+1)." ";
52 }
53 return $ret;
54 }
55 $pageindex=taotrang("select count(*) from support","./?act=online"."&page=",$MAXPAGE,$page);
56 ?>
57
58 <table cellspacing="0" cellpadding="0">
59 <tr>
60 <td class="smallfont">Trang : <? echo $pageindex; ?></td>
61 </tr>
62 </table>
63
64 <table border="1" cellpadding="2" style="border-collapse: collapse" bordercolor="#C9C9C9" width="100%" id="AutoNumber1">
65 <tr>
66 <td align=center nowrap class="title"><input type="checkbox" name="chkall" onclick="chkallClick(this);"></td>
67 <td nowrap class="title"> </td>
68 <td nowrap class="title"> </td>
69 <td align="center" nowrap class="title"><b>Mã</b></td>
70 <td align="center" nowrap class="title"><b>Tên trực tuyến</b></td>
71 <td align="center" nowrap class="title"><b>Yahoo ID</b></td>
72 <td align="center" nowrap class="title"><b>Điện thoại</b></td>
73 <td align="center" nowrap class="title"><b>Email</b></td>
74 <td align="center" nowrap class="title"><b>Thu tu</b></td>
75 <td align="center" nowrap class="title"><b>Ngày</b></td>
76 </tr>
77
78 <?
79 $sql="select * from support order by id limit ".($p*$MAXPAGE).",".$MAXPAGE;
80 $result=mysql_query($sql,$con);
81 $i=0;
82 while(($row=mysql_fetch_array($result)))
83 {
84 $i++;
85 if ($i%2) $color="#d5d5d5"; else $color="#e5e5e5";
86 ?>
87
88 <tr>
89 <td width="20" align="center" bgcolor="<? echo $color; ?>" class="smallfont">
90 <input type="checkbox" name="chk[]" value="<? echo $row['id']; ?>"></td>
91 <td width="20" bgcolor="<? echo $color; ?>" class="smallfont">
92 <a href="./?act=online_m&page=<? echo $_REQUEST['page']; ?>&id=<? echo $row['id']; ?>">Sửa</a></td>
93 <td width="20" bgcolor="<? echo $color; ?>" class="smallfont">
94 <a onclick="return confirm('Bạn có chắc chắn muốn xoá ?');" href="./?act=online&action=del&page=<? echo $_REQUEST['page']; ?>&id=<? echo $row['id']; ?>">Xoá</a></td>
95 <td width="20" bgcolor="<? echo $color; ?>" align="left" width="55" align="left" class="smallfont"><? echo $row['id']; ?> </td>
96 <td bgcolor="<? echo $color; ?>" class="smallfont"><? echo $row['name']; ?> </td>
97 <td bgcolor="<? echo $color; ?>" class="smallfont"><? echo $row['yahoo']; ?> </td>
98 <td width="80" bgcolor="<? echo $color; ?>" class="smallfont"><? echo $row['phone']; ?> </td>
99 <td width="80" bgcolor="<? echo $color; ?>" class="smallfont"><? echo $row['email']; ?> </td>
100 <td width="80" bgcolor="<? echo $color; ?>" class="smallfont"><? echo $row['thutu']; ?> </td>
101 <td width="100" bgcolor="<? echo $color; ?>" class="smallfont"><? echo $row['date']; ?> </td>
102 </tr>
103 <?
104 }
105 ?>
106 </table>
107 <input type="submit" value="Xóa Chọn" name="ButDel" onclick="return confirm('Bạn có chắc chắn muốn xoá ?');" class="button" style="padding: 0">
108 </form>
109 <script language="JavaScript">
110 function chkallClick(o) {
111 var form = document.frmList;
112 for (var i = 0; i < form.elements.length; i++) {
113 if (form.elements[i].type == "checkbox" && form.elements[i].name!="chkall") {
114 form.elements[i].checked = document.frmList.chkall.checked;
115 }
116 }
117 }
118 </script>